<template>
  <view class="applicationSeal">
    <u-form ref="uForm" :model="ruleForm" label-width="160">
      <!-- <u-form-item label="印章类型" prop="sealType" required>
        <u-radio-group v-model="ruleForm.sealType" @change="changeSealType">
          <u-radio name="entity"> 加盖实体章</u-radio>
          <u-radio name="electron"> 加盖电子章</u-radio>
        </u-radio-group>
      </u-form-item> -->
      <u-form-item :label="$t('申请单名称')" prop="applicationName" required>
        <u-input v-model="ruleForm.applicationName" border/>
      </u-form-item>
      <u-form-item
          :border-bottom="ruleForm.file.length > 0 ? false : true"
          :label="$t('申请材料')"
          prop="file"
          required
      >
        <u-button slot="right" size="mini" type="primary" @click="createUpload">{{ $t('选取') }}</u-button>
      </u-form-item>
      <u-form-item v-if="ruleForm.file.length > 0">
        <uni-list :border="false" style="width: 720rpx">
          <uni-list-item
              v-for="(item, index) in ruleForm.file"
              :key="index"
              :border="false"
              :ellipsis="1"
              :thumb="computedFileType(item)"
              :title="item.file.fileName"
              clickable
              style="width: 720rpx"
          >
            <view slot="footer" style="color: #888; display: flex; align-items: center">
              <u-tag :text="$t('预览')" type="success" @click="seeFileFn(item)"/>
              <u-icon
                  name="close-circle"
                  size="40"
                  style="margin-left: 20rpx"
                  @click="deleteFileFn(item)"
              ></u-icon>
            </view>
          </uni-list-item>
        </uni-list>
      </u-form-item>
      <u-form-item
          :border-bottom="ruleForm.device.length > 0 ? false : true"
          :label="$t('加盖印章')"
          prop="device"
          required
      >
        <u-button
            v-show="ruleForm.device.length === 0"
            slot="right"
            size="mini"
            type="primary"
            @click="secrecy_seal('加盖')"
        >
          {{ $t('选取') }}
        </u-button>
      </u-form-item>
      <u-form-item v-if="ruleForm.device.length > 0">
        <uni-list :border="false" style="width: 720rpx">
          <uni-list-item
              v-for="(item, index) in ruleForm.device"
              :key="index"
              :border="false"
              :ellipsis="1"
              :title="item.label"
              clickable
          >
            <view slot="footer" style="color: #888">
              <u-icon
                  name="close-circle"
                  size="40"
                  style="margin-left: 10px"
                  @click="deleteDeviceFn(item)"
              ></u-icon>
            </view>
          </uni-list-item>
        </uni-list>
      </u-form-item>
      <u-form-item :label="ruleForm.approvalMethod === 'process' ? $t('审批流程') : $t('审批人')"
                   :label-style="{ color: '#888' }">
        <view style="flex: 1;"></view>
        <u-radio-group v-model="ruleForm.approvalMethod" @change="approvalMethodChange">
          <u-radio v-if="approvalAndKeeperType.isFlow" name="process">审批流程</u-radio>
          <u-radio v-if="approvalAndKeeperType.isManager" name="user">审批人</u-radio>
        </u-radio-group>
      </u-form-item>

      <block v-if="ruleForm.approvalMethod === 'process'">
        <u-form-item
            :border-bottom="!ruleForm.auditProcess.length"
            :label="$t('审批流程')"
            prop="auditProcess"
            required
        >
          <u-button
              v-show="ruleForm.auditProcess.length === 0"
              slot="right"
              size="mini"
              type="primary"
              @click="secrecy_seal('审批流程')"
          >
            {{ $t('选取') }}
          </u-button>
        </u-form-item>
        <u-form-item v-if="ruleForm.auditProcess.length > 0">
          <uni-list :border="false" style="width: 720rpx">
            <uni-list-item
                v-for="(item, index) in ruleForm.auditProcess"
                :key="index"
                :border="false"
                :ellipsis="1"
                :title="item.name"
                clickable
            >
              <view slot="footer" style="color: #888">
                <u-icon
                    name="close-circle"
                    size="40"
                    style="margin-left: 20rpx"
                    @click="deleteAuditProcessFn(item)"
                ></u-icon>
              </view>
            </uni-list-item>
          </uni-list>
        </u-form-item>
        <u-form-item
            v-if="ruleForm.isShowOptional"
            :border-bottom="!ruleForm.isShowOptional"
            :label="$t('自选审批人')"
            prop="optionalUserId"
            required
        >
          <!--          <text>{{ruleForm.optionalUserName}}</text>-->
          <u-button slot="right" size="mini" type="primary" @click="secrecy_seal('自选审批人')">
            {{ $t('选取') }}
          </u-button>
        </u-form-item>
        <!--        <u-form-item v-if="ruleForm.optionalUserId">-->
        <!--          <text>自选审批人：{{ ruleForm.optionalUserName}} </text>-->
        <!--        </u-form-item>-->
        <u-form-item v-if="ruleForm.optionalUserId">
          <uni-list :border="false" style="width: 720rpx">
            <uni-list-item
                :border="false"
                :title="ruleForm.optionalUserName"
                clickable
            >
              <view slot="footer" style="color: #888">
                <u-icon
                    name="close-circle"
                    size="40"
                    style="margin-left: 20rpx"
                    @click="deleteOptionalUser"
                />
              </view>
            </uni-list-item>
          </uni-list>
        </u-form-item>
      </block>
      <block v-else>
        <u-form-item
            :border-bottom="!ruleForm.auditUser.length"
            :label="$t('审批人')"
            prop="auditUser"
            required
        >
          <u-button slot="right" size="mini" type="primary" @click="secrecy_seal('审批人')">
            {{ $t('选取') }}
          </u-button>
        </u-form-item>
        <u-form-item v-if="ruleForm.auditUser.length > 0">
          <uni-list :border="false" style="width: 720rpx">
            <uni-list-item
                v-for="(item, index) in ruleForm.auditUser"
                :key="index"
                :border="false"
                :ellipsis="1"
                :title="item.label"
                clickable
            >
              <view slot="footer" style="color: #888">
                <u-icon
                    name="close-circle"
                    size="40"
                    style="margin-left: 20rpx"
                    @click="deleteAuditUserFn(item)"
                ></u-icon>
              </view>
            </uni-list-item>
          </uni-list>
        </u-form-item>
      </block>
      <u-form-item
          v-if="entitySeal && entitySeal.supportApplicationType === true"
          v-show="ruleForm.device.length > 0"
          :label="$t('申请类型')"
          prop="applicationTypeName"
      >
        <u-input
            v-model="ruleForm.applicationTypeName"
            :clearable="true"
            :placeholder="$t('请选择')"
            :select-open="select.show"
            border
            type="select"
            @clear="clearFn"
            @click="select.show = true"
        />
      </u-form-item>
      <u-form-item v-if="selectUser.list.length > 0" :label="$t('专人用章')" prop="sealUserName">
        <u-input
            v-model="ruleForm.sealUserName"
            :clearable="false"
            :placeholder="$t('请选择')"
            :select-open="selectUser.show"
            border
            type="select"
            @click="selectUser.show = true"
        />
      </u-form-item>
      <block v-if="entitySeal && entitySeal.ocrTextRecognition === true">
        <u-form-item :label="$t('盖印份数')" label-width="220" prop="contractCopiesNum" required>
          <u-number-box v-model="ruleForm.contractCopiesNum" :min="1"></u-number-box>
        </u-form-item>
        <u-form-item :label="$t('盖印次数')" label-width="220" prop="contractCopiesCount" required>
          <u-number-box v-model="ruleForm.contractCopiesCount" :min="1"></u-number-box>
        </u-form-item>
        <u-form-item :label="$t('盖印总次数')" label-width="220" prop="useCount" required>
          <u-number-box v-model="ruleForm.useCount" :min="1" disabled></u-number-box>
        </u-form-item>
      </block>
      <block v-else>
        <u-form-item :label="$t('盖印次数')" label-width="200" prop="useCount" required>
          <u-number-box v-model="ruleForm.useCount" :min="1"></u-number-box>
        </u-form-item>
      </block>
      <u-form-item :label="$t('申请说明')" prop="content">
        <u-input v-model="ruleForm.content" border type="textarea"/>
      </u-form-item>
    </u-form>
    <!-- 量子上传 -->
    <!-- <lz-file ref="lzFile" @up-success="QSSupSuccess" top="75px"></lz-file> -->
    <!-- #ifdef MP-WEIXIN -->
    <view class="submissionbtn">
      <u-button :loading="!btnOnoff" size="medium" type="primary" @click="submission">
        {{ $t('立即提交') }}
      </u-button>
    </view>
    <!-- #endif -->

    <!-- 申请类型 -->
    <u-select
        v-model="select.show"
        :list="select.list"
        label-name="name"
        value-name="id"
        @confirm="selectconfirm"
    ></u-select>

    <!-- 自选审批人 -->
    <u-select
        v-model="optionalUserPicker.visible"
        :list="optionalUserPicker.list"
        label-name="label"
        value-name="key"
        @confirm="optionalUserPickerConfirm"
    ></u-select>

    <!-- 专人用章 -->
    <u-select
        v-model="selectUser.show"
        :list="selectUser.list"
        label-name="userName"
        value-name="id"
        @confirm="selectUserfirm"
    ></u-select>

    <!-- #ifdef MP-WEIXIN -->
    <!-- 微信隐私弹框 -->
    <u-popup v-model="popup.show" mode="center">
      <view class="ws-privacy-popup">
        <view class="ws-privacy-popup__header">
          <!--标题-->
          <view class="ws-picker__title">{{ $t('用户隐私保护提示') }}</view>
        </view>
        <view class="ws-privacy-popup__container">
          <text>{{ $t('感谢您使用本应用，您使用本应用的服务之前请仔细阅读并同意') }}</text>
          <text class="ws-privacy-popup__container-protocol" @click="openPrivacyContract">
            《{{ $t('用户隐私保护指引') }}》
          </text>
          <text>
            。{{ $t('当您点击同意并开始使用产品服务时，即表示你已理解并同意该条款内容，该条款将对您产生法律约束力。如您拒绝，将无法使用相应服务。') }}
          </text>
        </view>
        <view class="ws-privacy-popup__footer">
          <button
              id="agree-btn"
              class="is-agree"
              open-type="agreePrivacyAuthorization"
              @agreeprivacyauthorization="handleAgree"
          >
            {{ $t('同意并继续') }}
          </button>
          <button id="disagree-btn" class="is-disagree" @click="handleDisagree">{{ $t('不同意') }}</button>
        </view>
      </view>
    </u-popup>
    <!-- #endif -->
  </view>
</template>

<script>
import {mapGetters, mapMutations} from 'vuex'
import {requestAndroidPermission} from '@/uni_modules/x-perm-apply-instr/js_sdk/index.js'
import {urlAddParams} from '@/utils/urlAddParams.js'
export default {
  computed: {
    ...mapGetters(['userInfo', 'api', 'userToken']),
    //计算图片属性
    computedFileType() {
      return (item) => {
        return this.$lizhao.file.lzGetFileType(item.type)
      }
    }
  },
  components: {},
  data() {
    return {
      btnOnoff: true, //控制多次提交
      // 自选审批人
      optionalUserPicker: {
        visible: false,
        list: []
      },
      ruleForm: {
        sealType: 'entity', //electron电子章，entity实体章
        applicationName: '', //用章文件名
        content: '', //申请说明
        file: [], //上传的附件
        device: [], //加盖印章
        applicationTypeId: '', //申请类型
        applicationTypeName: '', //申请类型名称
        approvalMethod: 'process',
        auditUser: [], //审批人
        auditProcess: [], //审批流程
        isShowOptional: false, //当第一个审批流程节点为审批人自选时则展示选择审批人
        optionalUserId: '', // 自选人id
        optionalUserName: '', // 自选人名称
        departmentId: '', //已选择的组织id
        useCount: 1, //盖印次数
        contractCopiesNum: 1, //份数
        contractCopiesCount: 1, //次数
        sealUserId: '', //专人
        sealUserName: '' //专人
      },
      rules: {
        applicationName: [
          {
            required: true,
            message: this.$t('必填'),
            trigger: ['change']
          }
        ],
        sealType: [
          {
            required: true,
            message: this.$t('必填'),
            trigger: ['change']
          }
        ],
        file: [
          {
            validator: (rule, value, callback) => {
              return this.ruleForm.file.length > 0
            },
            message: this.$t('必填'),
            trigger: ['change']
          }
        ],
        device: [
          {
            validator: (rule, value, callback) => {
              return this.ruleForm.device.length > 0
            },
            message: this.$t('必填'),
            trigger: ['change', 'blur']
          }
        ],
        auditUser: [
          {
            validator: (rule, value, callback) => {
              return this.ruleForm.auditUser.length > 0
            },
            message: this.$t('必填'),
            trigger: ['change', 'blur']
          }
        ],
        auditProcess: [
          {
            validator: (rule, value, callback) => {
              return this.ruleForm.auditProcess.length > 0
            },
            message: this.$t('必填'),
            trigger: ['change', 'blur']
          }
        ]
      },
      select: {
        show: false,
        list: []
      },
      entitySeal: null, //当前选中的实体章信息
      selectUser: {
        show: false,
        list: [] //专人用章列表
      },
      popup: {
        show: false
      },
      approvalAndKeeperType: {
        isFlow: 1, //是否启用审批流程
        isManager: 1, //是否启用审批人
        isKeeper: 0 //是否跳过授权节点
      }
    }
  },
  watch: {
    'ruleForm.contractCopiesNum'(data) {
      this.ruleForm.useCount = this.ruleForm.contractCopiesCount * this.ruleForm.contractCopiesNum
    },
    'ruleForm.contractCopiesCount'(data) {
      this.ruleForm.useCount = this.ruleForm.contractCopiesCount * this.ruleForm.contractCopiesNum
    }
  },
  mounted() {
    uni.setNavigationBarTitle({title: this.$t('申请用章')})
    this.getApprovalMethod()
  },
  methods: {
    approvalMethodChange(val) {
      console.log('approvalMethodChange', val)
    },
    getApprovalMethod() {
      try {
        this.$u.get('/application/flow/approvalAndKeeperType', {}).then(res => {
          console.log('getApprovalMethod', res)
          if (res.success && res.data) {
            this.approvalAndKeeperType = res.data
            this.ruleForm.approvalMethod = this.approvalAndKeeperType.isFlow === 1 ? 'process' : 'user'
          }
        })
      } catch (error) {
        console.log(error)
      }
    },
    deleteOptionalUser() {
      this.ruleForm.optionalUserId = ''
      this.ruleForm.optionalUserName = ''
    },
    optionalUserPickerConfirm(e) {
      console.log('optionalUserPickerConfirm', e)
      this.ruleForm.optionalUserId = e[0].value
      this.ruleForm.optionalUserName = e[0].label
    },
    // 同意隐私协议
    handleAgree() {
      this.popup.show = false
      this.createUpload()
    },
    // 拒绝隐私协议
    handleDisagree() {
      this.popup.show = false
    },
    // 打开隐私协议
    openPrivacyContract() {
      wx.openPrivacyContract({
        success: (res) => {
          //console.log('openPrivacyContract success')
        },
        fail: (res) => {
          console.error('openPrivacyContract fail', res)
        }
      })
    },
    // 查询微信侧记录的用户是否有待同意的隐私政策信息
    getPrivacySetting() {
      wx.getPrivacySetting({
        success: (res) => {
          //console.log(res) // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' }
          if (res.needAuthorization) {
            // 需要弹出隐私协议
            this.popup.show = true
          } else {
            // 用户已经同意过隐私协议，所以不需要再弹出隐私协议，也能调用已声明过的隐私接口
            this.choseFile()
          }
        },
        fail: () => {
        },
        complete: () => {
        }
      })
    },
    clearFn() {
      this.ruleForm.applicationTypeId = ''
      this.ruleForm.applicationTypeName = ''
      this.selectUser.list = []
      this.ruleForm.sealUserId = ''
      this.ruleForm.sealUserName = ''
      this.ruleForm.isShowOptional = false
    },
    selectUserfirm(data) {
      this.ruleForm.sealUserId = data[0].value || ''
      this.ruleForm.sealUserName = data[0].label || ''
    },
    selectconfirm(data) {
      this.ruleForm.applicationTypeId = data[0].value || ''
      this.ruleForm.applicationTypeName = data[0].label || ''
      let item = this.select.list.find((item) => item.id === data[0].value)
      if (item && item.appointSealUserEnabled === true) {
        // 获取专人列表
        this.getUserList()
      } else {
        this.selectUser.list = []
        this.ruleForm.sealUserId = ''
        this.ruleForm.sealUserName = ''
      }
    },
    //获取专人列表
    getUserList() {
      //console.log(this.ruleForm.device[0]);
      let req = {
        page: false,
        applicationTypeId: this.ruleForm.applicationTypeId,
        deviceId: this.ruleForm.device[0].value
      }
      this.$u.get(this.api.GLOBAL_application_type_findSealUserInfos, req).then((res) => {
        if (res.code === 200 && res.data) {
          this.selectUser.list = res.data
        } else {
          this.selectUser.list = []
        }
      })
    },
    //获取申请类型
    getapplicationTypeList(res) {
      let req = {
        page: false,
        deviceId: res.value
      }
      this.$u.get(this.api.GLOBAL_application_type_findSimpleList, req).then((res) => {
        if (res.code === 200 && res.data) {
          this.select.list = res.data
        } else {
          this.select.list = []
        }
      })
    },
    //接收加盖印章
    data_cover(res) {
      this.ruleForm.device.push(res)
      this.entitySeal = res.data
      //去重
      this.ruleForm.device = this.$lizhao.es6.arrayUnique(this.ruleForm.device, 'value')
      if (res.data.supportApplicationType === true) {
        this.getapplicationTypeList(res)
      }
    },
    //接收审批人
    data_audit(res) {
      this.ruleForm.auditUser = res
    },
    //接收审批流程
    Approval_process(res) {
      console.log('接收审批流程', res)
      this.ruleForm.auditProcess = this.ruleForm.auditProcess.concat(res)
      if (res.optionals && res.optionals.length) {
        this.optionalUserPicker.list = res.optionals
        this.ruleForm.isShowOptional = true
      } else {
        this.ruleForm.isShowOptional = false
        this.optionalUserPicker.list = []
        this.ruleForm.optionalUserId = ''
        this.ruleForm.optionalUserName = ''
      }
    },
    //切换盖章类型
    changeSealType(data) {
      this.$emit('changeSealType', data)
    },
    //点击提交
    navigationBarButtonTap(e) {
      if (e.index === 0 && this.btnOnoff) {
        uni.showLoading({
          title: this.$t('提交中') + '...',
          mask: false
        })
        //点击提交
        this.submission()
      }
    },
    // onReady方法触发
    readyFn() {
      this.$refs.uForm.setRules(this.rules)
    },
    //提交
    submission() {
      if (this.ruleForm.useCount > 9999) {
        uni.showToast({
          title: `${this.$t('最大次数')}:9999`,
          icon: 'none'
        })
        return
      }
      this.$refs.uForm.validate((valid) => {
        if (valid) {
          this.btnOnoff = false
          let fileIds = this.ruleForm.file.map((item) => {
            return item.id
          })
          let deviceIds = this.ruleForm.device.map((item) => {
            return item.value
          })
          let managerIds = this.ruleForm.auditUser.map((item) => {
            return item.key
          })
          let processId = this.ruleForm.auditProcess.map((item) => {
            return item.id
          })
          let req = {
            fileIds: fileIds.join(','), //头像列表id
            deviceId: deviceIds.join(','), //章的id
            applicationName: this.ruleForm.applicationName, //申请主题
            content: this.ruleForm.content, //申请说明
            useCount: this.ruleForm.useCount, //印章的盖印次数
            managerIds: managerIds.join(','), //审批人id
            processId: processId.join(','), //审批流程id
            departmentId: this.ruleForm.departmentId, //当审批流程有直接主管就要选择组织
            applicationTypeId: this.ruleForm.applicationTypeId, //申请类型
            contractCopiesNum: this.ruleForm.contractCopiesNum, //申请份数
            contractCopiesCount: this.ruleForm.contractCopiesCount, //申请次数
            sealUserId: this.ruleForm.sealUserId, //专人
            optionalUserId: this.ruleForm.optionalUserId, // 自选审批人
          }
          console.log('GLOBAL_application_application_add.req', req)
          this.$u.post(this.api.GLOBAL_application_application_add, req).then((res) => {
            uni.hideLoading()
            if (res.code === 200) {
              uni.showToast({
                title: res.msg,
                icon: 'success',
                duration: 1000
              })
              setTimeout(() => {
                uni.navigateBack({
                  delta: 1
                })
              }, 1000)
            }
            this.btnOnoff = true
          })
        }
      })
    },
    //开关改变
    switchChange(e) {
      //console.log(e);
      if (e) {
        this.ruleForm.auditUser = []
      } else {
        this.ruleForm.auditProcess = []
        this.ruleForm.departmentId = ''
      }
      this.ruleForm.isShowOptional = false
    },
    //取消选取组织
    pickerCancel() {
      this.ruleForm.auditProcess = []
      this.ruleForm.departmentId = ''
    },
    //确认选取组织
    pickerConfirm(departmentId) {
      this.ruleForm.departmentId = departmentId
    },
    //审批人删除
    deleteAuditUserFn(item) {
      this.ruleForm.auditUser = this.ruleForm.auditUser.filter((res) => res.key !== item.key)
    },
    //审批流程删除
    deleteAuditProcessFn(item) {
      this.ruleForm.auditProcess = []
      this.ruleForm.departmentId = ''
    },
    //印章删除
    deleteDeviceFn(item) {
      this.ruleForm.device = this.ruleForm.device.filter((res) => res.value !== item.value)
      //清空申请类型
      this.ruleForm.applicationTypeId = ''
      this.ruleForm.applicationTypeName = ''
      this.ruleForm.contractCopiesCount = 1
      this.ruleForm.contractCopiesNum = 1
      this.entitySeal = null
      this.select.list = []
      //清空专人
      this.selectUser.list = []
      this.ruleForm.sealUserId = ''
      this.ruleForm.sealUserName = ''
    },
    //保密级别 //加盖印章 //审批人
    secrecy_seal(val) {
      this.current_type = val //用于确认
      if (val === '保密') {
        this.pickerValueArray = this.secrecyData
      }
      if (val === '加盖') {
        uni.navigateTo({
          url: '../../template/index-list/index-list?type=加盖印章'
        })
        return
      }
      if (val === '审批流程') {
        if (this.ruleForm.device.length > 0) {
          uni.navigateTo({
            url:
                '../../template/index-list/index-list?type=审批流程&deviceId=' +
                this.ruleForm.device[0].value
          })
        } else {
          uni.showToast({
            title: this.$t('请先选择加盖印章'),
            icon: 'none'
          })
        }
        return
      }
      if (val === '审批人') {
        if (this.ruleForm.device.length > 0) {
          uni.navigateTo({
            url: `../../template/mailList/mailList?type=审批人&deviceId=${this.ruleForm.device[0].value}&data=${JSON.stringify(this.ruleForm.auditUser)}`
          })
        } else {
          uni.showToast({
            title: this.$t('请先选择加盖印章'),
            icon: 'none'
          })
        }
      }
      if (val === '自选审批人') {
        this.optionalUserPicker.visible = true
      }
    },
    //浏览附件
    seeFileFn(item) {
      let screenWidth = uni.getWindowInfo().screenWidth * 1
      if (this.$lizhao.file.lzGetTypeSuffix(item.type) === 'image') {
        console.log('预览图片', screenWidth)
        const originUrl = item.file.url.split('?')[0]
        console.log('originUrl', originUrl)
        const urls = [urlAddParams(originUrl, {Authorization: this.userInfo.token, us: 'app', width: screenWidth})]
        console.log('urls', urls)
        uni.previewImage({
          current: 0,
          urls: urls
        })
      } else if (this.$lizhao.file.lzGetTypeSuffix(item.type) === 'word') {
        this.$lizhao.download.file(
            item.file.url + '?Authorization=' + this.userInfo.token + '&us=app'
        )
      }
    },
    //附件删除
    deleteFileFn(item) {
      this.ruleForm.file = this.ruleForm.file.filter((res) => res.id !== item.id)
    },
    //上传附件
    createUpload() {
      // #ifdef MP-WEIXIN
      this.getPrivacySetting()
      // #endif
      // #ifndef MP-WEIXIN
      this.choseFile()
      // #endif
    },
    choseFile() {
      if (getApp().globalData.GK_QSS_ONOFF.application) {
        console.log('调用文件管理系统选取文件')
        //量子选取文件
        //调用文件管理系统选取文件
        this.documentManagementSystem()
      } else {
        console.log('打开相机')
        requestAndroidPermission(['android.permission.CAMERA', 'android.permission.READ_EXTERNAL_STORAGE'], {
          title: '相机/相册/设备存储权限申请说明',
          content: '为了用户申请材料上传本地文件,我们需要申请您设备的相机/相册/存储权限。'
        }).then(status => {
          console.log('相机权限', status)
          // status 权限申请结果 （1:已获得权限, 0:拒绝本次申请, -1:永久拒绝申请）
          if (status == 1) {
            //非量子选取文件
            this.$emit('notQssFn', true)
          } else {
            uni.showToast({
              title: '没有相机权限',
              icon: 'none'
            })
          }
        })
      }
    },

    upSuccess(obj) {
      this.ruleForm.file.push(obj)
    }
  }
}
</script>

<style lang="scss">
.applicationSeal {
  background-color: #fff;
  height: 100%;
  box-sizing: border-box;
  padding: 0 30rpx;

  .submissionbtn {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 40rpx;
  }
}

.ws-privacy-popup {
  padding: 48rpx;
  box-sizing: border-box;
  overflow: hidden;
  width: 560rpx;
  background: linear-gradient(180deg, #e5edff 0%, #ffffff 100%);
  border-radius: 24rpx;

  &__header {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 52rpx;
    font-size: 36rpx;
    font-family: PingFangSC-Medium,
    PingFang SC;
    font-weight: 550;
    color: #1a1a1a;
    line-height: 52rpx;
    margin-bottom: 48rpx;
  }

  &__container {
    width: 100%;
    box-sizing: border-box;
    font-size: 28rpx;
    font-family: PingFangSC-Regular,
    PingFang SC;
    font-weight: 400;
    color: #333333;
    line-height: 48rpx;
    margin-bottom: 48rpx;

    &-protocol {
      font-weight: 550;
      color: #4d80f0;
    }
  }

  &__footer {
    display: flex;
    flex-direction: column;

    .is-disagree,
    .is-agree {
      width: 100%;
      height: 88rpx;
      background: #ffffff;
      border-radius: 44rpx;
      font-size: 32rpx;
      font-family: PingFangSC-Regular,
      PingFang SC;
      font-weight: 400;
      color: #666666;
    }

    .is-agree {
      background: #4d80f0;
      color: #ffffff;
      margin-bottom: 18rpx;
    }

    button {
      border: none;
      outline: none;

      &::after {
        border: none;
      }
    }
  }
}
</style>
